package leetcode.D100.T11;

/**
 * @File Info: leetcode -- <Solution>
 * @Author: DYZ
 * @Create: 2021-08-08 21:05:10 星期日
 */

public class Solution {
    public int maxArea(int[] height) {
        int i = 0, j = height.length-1;
        int res = 0;
        while(i < j) {
            int h = Math.min(height[i], height[j]);
            res = Math.max(res, (j-i) * h);
            while(i < j && height[i] <= h) {
                ++i;
            }
            while(i < j && height[j] <= h) {
                --j;
            }
        }
        return res;
    }
}
